package May;

import com.sun.org.apache.xml.internal.security.utils.HelperNodeList;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class DAY0531 {
    //洗牌

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();

        for (int i = 0; i < num; i++) {
            // n：2n即牌的数量
            // k：洗牌的次数
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            //把牌分为两堆
            ArrayList<Integer> card = new ArrayList<>();
            ArrayList<Integer> cards1 = new ArrayList<>();
            ArrayList<Integer> cards2 = new ArrayList<>();

            // 获得要洗牌的所有数
            for (int j = 0; j < 2 * n; j++) {
                card.add(scanner.nextInt());
            }
            Collections.reverse(card);// 反转

            for (int x = 0; x < k; x++) {
                cards1.clear();
                cards2.clear();

                //小于n的
                for (int j = 0; j < n; j++) {
                    cards1.add(card.get(j));
                }

                // 大于n的
                for (int j = n; j < 2 * n; j++) {
                    cards2.add(card.get(j));
                }

                // 洗牌
                card.clear();
                for (int j = 0; j < n; j++) {
                    card.add(cards1.get(j));
                    card.add(cards2.get(j));
                }
            }

            Collections.reverse(card);// 再把牌组顺序反转为正常顺序
            System.out.println(
                    card.toString()
                            .replace("[", "")
                            .replace("]", "")
                            .replace(",", ""));
        }
    }


    //mp3光标的位置
    public static void main(String[] args) {
        Scanner scanner =new Scanner(System.in);
        while (scanner.hasNextInt()){
            int n = scanner.nextInt();//接收有多少歌曲
            String num = scanner.next();//接收要进行的命令
            //将小于等于4与大于4分开写成两个函数，分别调用
            if (n<=4){
                cursor(num,n);
            }else {
                cursors(num,n);
            }
        }


    }

    //大于4
    private static void cursors(String num, int n) {
        char[] arr = num.toCharArray();
        int b =1;
        int cur = 1;
        //大于4有页数概念
        for (int i = 0; i < arr.length; i++) {
            //如果在第一页 第一个 且是U
            if (b == 1&& cur == 1&& arr[i] == 'U'){
                cur = n;
                b = n-3;
                continue;
            }
            //如果是最后一页  最后一个 且是D
            if (b == n-3 && cur == n&&arr[i] == 'D'){
                cur = 1;
                b = 1;
                continue;
            }
            if (arr[i] == 'U' && b == cur){
                cur = cur-1;
                b = b-1 ;
                continue;
            }
            if (arr[i] == 'D' && b+3 == cur){
                cur = cur+1;
                b = b+1 ;
                continue;
            }
            if (arr[i] == 'U'){
                cur = cur-1;
            }else {
                cur = cur+1;
            }
        }
        System.out.println(b + " " + (b + 1) + " " + (b + 2)+ " " + (b + 3));
        System.out.println(cur);
    }

    //小于等于4
    private static void cursor(String num, int n) {
        char[] arr = num.toCharArray();

        int b = 1;
        int cur = 1;
        for (int i = 0; i < arr.length; i++) {
            //当前光标位置在1的位置上，且命令为 U需要跳转到第n个位置上
            if (cur == 1&&arr[i] == 'U'){
                cur = n;
                continue;
            }
            if (cur == n && arr[i]== 'D'){
                cur = 1;
                continue;
            }
            if (arr[i] == 'U'){
                cur = cur-1;
            }
            if (arr[i] == 'D'){
                cur = cur+1;
            }
        }

        //输出  当前列表和选中歌曲
        for (int i = 0; i < n; i++) {
            if (i == 0){
                System.out.print(b);
            }else {
                System.out.print(" "+(b+i));
            }
        }
        System.out.println();
        System.out.println(cur);
    }
}
